package com.ycz.sas.jgen.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ycz.sas.jgen.manager.UserManager;

@Service
public class UserService {
	
	@Autowired
	private UserManager userManager;
	
	public Map<String, String> getUserInfo(String username) throws SQLException, ClassNotFoundException {
		
		ResultSet set = userManager.findUserByName(username.trim());
		
		String userid = null;
		String password = null;
		
		if(set.next()){
			userid = set.getString("fid");
			password = set.getString("fpassword");
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put("id", userid);
		map.put("password", password);
		return map;
	}

	public UserManager getUserManager() {
		return userManager;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}
	
	
	

}
